<?php

class AuthorizedAppInfo extends \Phalcon\Mvc\Model
{

    /**
     *
     * @var integer
     */
    public $id;

    /**
     *
     * @var string
     */
    public $app_id;

    /**
     *
     * @var string
     */
    public $nick_name;

    /**
     *
     * @var string
     */
    public $head_img;

    /**
     *
     * @var integer
     */
    public $service_type_info;

    /**
     *
     * @var integer
     */
    public $verify_type_info;

    /**
     *
     * @var string
     */
    public $raw_id;

    /**
     *
     * @var string
     */
    public $principal_name;

    /**
     *
     * @var string
     */
    public $alias;

    /**
     *
     * @var string
     */
    public $qrcode_url;

    /**
     *
     * @var string
     */
    public $authorization_info;

    /**
     *
     * @var integer
     */
    public $enabled;

    /**
     *
     * @var string
     */
    public $gmt_created;

    /**
     *
     * @var string
     */
    public $gmt_updated;

    public $type;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        $this->setSource("authorized_app_info");
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'authorized_app_info';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return AuthorizedAppInfo[]|AuthorizedAppInfo|\Phalcon\Mvc\Model\ResultSetInterface
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return AuthorizedAppInfo|\Phalcon\Mvc\Model\ResultInterface
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    public function beforeValidationOnCreate()
    {
        $this->gmt_created = date('Y-m-d H:i:s',time());
        $this->gmt_updated = date('Y-m-d H:i:s',time());
    }

    public function beforeCreate(){
        $this->gmt_created = date('Y-m-d H:i:s',time());
        $this->gmt_updated = date('Y-m-d H:i:s',time());
    }

    public function beforeUpdate(){
        $this->gmt_updated = date('Y-m-d H:i:s',time());
    }

}
